/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iterators;
import java.util.*;
import IA.*;
/**
 *
 * @author Jeremy
 */
public class AvailableTableItr implements Iterator<Table> {
    private ArrayList<Table> _tables;
    public AvailableTableItr(ArrayList<Table> Tables) {
        _tables = (ArrayList<Table>)Tables.clone();
        //filter out all table that aren't available
        for(Iterator<Table> itr = _tables.iterator(); itr.hasNext(); ) {
            Table t = itr.next();
            if(!t.getIsAvailable()) itr.remove();
        }
    }

    @Override
    public boolean hasNext() {
        return !_tables.isEmpty();
    }

    @Override
    public Table next() {
        return _tables.remove(0);
    }

    @Override
    public void remove() {
       
    }
}
